<div style="height:30px;border-bottom:4px solid #DFDFDF;">
    <p class="pull-left" style="font-size:16px; line-height:30px;">
        <strong><?php echo $this->translate('批量订单发货'); ?></strong></p>

    <p class="pull-right">
        <a href="<?php echo $this->url('orders/default/page', array('controller' => 'Orders', 'action' => 'index')); ?>"
           class="btn btn-small"><i class="icon-arrow-left"></i> <?php echo $this->translate('返回订单列表'); ?></a>&nbsp;
        <a href="<?php echo $this->myviewalias()->dbshopHelpUrl('order_moreshipoper'); ?>" target="_blank"
           class="btn btn-small btn-info"><i
                class="icon-info-sign icon-white"></i> <?php echo $this->translate('查看帮助说明'); ?></a>
    </p>
</div>
<table class="table table-hover">
    <thead style="background:#CCC;">
    <tr>
        <th width="10%"><?php echo $this->translate('配送方式'); ?></th>
        <th width="10%"><?php echo $this->translate('待发货订单'); ?></th>
        <th width="10%"><?php echo $this->translate('可用快递单号'); ?></th>
        <th width="10%"><?php echo $this->translate('已用快递单号'); ?></th>
        <th width="8%"><?php echo $this->translate('操作'); ?></th>
    </tr>
    </thead>
    <?php
    if ($this->express_array) {
        foreach ($this->express_array as $express_val) {
            ?>
            <tr>
                <td><?php echo $this->escapeHtml($express_val['express_name']); ?></td>
                <td><?php echo $express_val['order_num']; ?></td>
                <td><?php echo $express_val['express_number_total']; ?></td>
                <td><?php echo $express_val['used_express_number_total']; ?></td>
                <td>
                    <a href="javascript:;" onclick="ship_oper_js(<?php echo $express_val['express_id']; ?>, '<?php echo $this->escapeHtml($express_val['express_name']); ?>', <?php echo $express_val['order_num']; ?>, <?php echo $express_val['express_number_total']; ?>);"><?php echo $this->translate('点击批量发货'); ?></a>
                </td>
            </tr>
        <?php
        }
    }
    ?>
</table>
<form class="form-horizontal" name="shipoper_form" id="shipoper_form" action="<?php echo $this->url('orders/default',array('action'=>'allShipOper','controller'=>'Orders')); ?>" method="post">
    <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel"></h3>
        </div>
        <div class="modal-body">
            <input type="hidden" name="express_id" id="express_id" value="" />
            <div class="control-group">
                <label class="control-label"><?php echo $this->translate('待发货订单'); ?></label>
                <div class="controls">
                    <input type="text" readonly id="order_num_div" value="">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><?php echo $this->translate('可用快递单号'); ?></label>
                <div class="controls">
                    <input type="text" readonly id="express_number_total_div" value="">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><?php echo $this->translate('操作说明'); ?></label>
                <div class="controls">
                    <label class="help-inline"><p class="text-error"><?php echo $this->translate('只处理可用快递单号数的订单发货，多出的待发货订单不予处理。'); ?></p></label>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <button type="submit" id="button_id" class="btn btn-primary"><?php echo $this->translate('批量发货处理'); ?></button>
        </div>
    </div>
</form>
<script>
    function ship_oper_js(express_id, express_name, order_num, express_number_total) {
        var express_name_str = '<?php echo $this->translate('批量发货'); ?>-'+express_name;
        $('#myModalLabel').html(express_name_str);

        $('#express_number').val('');
        $('#express_id').val(express_id);
        $('#order_num_div').val(order_num);
        $('#express_number_total_div').val(express_number_total);
        if(express_number_total == 0) {
            $('#button_id').addClass('disabled');
        } else {
            $('#button_id').removeClass('disabled');
        }

        $('#myModal').modal('show');
    }
</script>